import 'package:cbec_app/components/base/base_nav_bar.dart';
import 'package:cbec_app/components/base/base_page.dart';
import 'package:cbec_app/components/common/not_found.dart';
import 'package:cbec_app/components/common/recommend.dart';
import 'package:cbec_app/components/order/comment_order_item.dart';
import 'package:cbec_app/components/order/order_item.dart';
import 'package:cbec_app/pages/my/controller/comment_orderlist_ctr.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

//订单待评价列表
class CommentOrderList extends GetView<CommentOrderListController> {
  CommentOrderList({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<CommentOrderListController>(builder: (controller) {
      return BasePage(
        title: "待评价",
        refreshController: controller.baseRefreshCtr,
        enablePullDown: true,
        enablePullUp: controller.hasNextPage,
        onPageRefresh: controller.onPageRefresh,
        onPageLoading: controller.onPageLoading,
        iconType: IconType.back,
        tabHeight: 30.h,
        tabChildren: [_Tabs()],
        children: [
          Center(
            child: Container(
              decoration: const BoxDecoration(
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(20), // 左侧圆角半径为20
                  topRight: Radius.circular(20), // 右侧圆角半径为20
                ),
                color: Colors.white, // 设置Container的背景颜色
              ),
              margin: EdgeInsets.only(top: 10.w, left: 8.w, right: 8.w),
              width: double.infinity,
              // child: _Tabs(),
            ),
          ),
          ListView.builder(
              itemCount: controller.orderList.length,
              shrinkWrap: true,
              physics: const NeverScrollableScrollPhysics(),
              itemBuilder: (context, index) {
                final List item = controller.orderList;
                return CommentOrderItem(
                  orderSn: item[index]['paySn'],
                  orderTime: item[index]['cd'],
                  totalAmount: item[index]['priceOrder'],
                  goodsList: item[index]['goodsInfo'],
                  id: item[index]['id'],
                  isShowPingJia: controller.type == 5,
                );
              }),
          Recommend()
        ],
      );
    });
  }

  /*

  controller.type == 5
                    ? OrderItem(
                        orderSn: item[index]['id'],
                        orderTime: item[index]['cd'],
                        totalAmount: item[index]['priceOrder'],
                        status: item[index]['status'],
                        goodsList: item[index]['goodsInfo'],
                        id: item[index]['id'],
                        sn: item[index]['sn'],
                        paySn: item[index]['paySn'],
                      )
                    :


   */

  /**
   *  订单状态
   */
  Widget _Tabs() {
    return SizedBox(
      height: 30,
      child: TabBar(
          dividerColor: Colors.transparent,
          indicator: const BoxDecoration(
            border: Border(
              bottom: BorderSide(width: 2, color: Colors.red),
            ),
          ),
          labelColor: Tools.fromHex("#F83F2D"),
          isScrollable: true,
          unselectedLabelColor: Colors.black,
          controller: controller.StatusTabController,
          tabAlignment: TabAlignment.center,
          tabs: [
            Tab(
              text: "待评价(${controller.waitNum})",
            ),
            Tab(
              text: "已评价(${controller.completeNum})",
            )
          ]),
    );
  }
}
